package com.wutma.friend.service.file.impl;

import com.wutma.common.core.enums.ResultCode;
import com.wutma.common.domain.COSResult;
import com.wutma.common.security.exception.ServiceException;
import com.wutma.common.service.COSService;
import com.wutma.friend.service.file.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private COSService cosService;
    @Override
    public COSResult upload(MultipartFile multipartFile) {

        COSResult cosResult = cosService.uploadFile(multipartFile);
        if (cosResult == null) {
            throw new ServiceException(ResultCode.FAILED_FILE_UPLOAD);
        }
        return cosResult;
    }
}
